:root {
        --bg0: #060a14;
        --bg1: #0b1220;
        --card: rgba(255, 255, 255, 0.06);
        --card2: rgba(255, 255, 255, 0.04);
        --text: #e8eefc;
        --muted: rgba(232, 238, 252, 0.65);
        --border: rgba(255, 255, 255, 0.10);
        --accent: #ff8a00;
        --danger: #ff4d4d;
        --ok: #18c37e;
        --warn: #f0b429;
        --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
        --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
      }

      * { box-sizing: border-box; }
      body {
        margin: 0;
        font-family: var(--sans);
        color: var(--text);
        background:
          radial-gradient(1000px 700px at 25% 10%, rgba(255, 138, 0, 0.16), transparent 55%),
          radial-gradient(1000px 700px at 80% 25%, rgba(255, 77, 77, 0.12), transparent 55%),
          linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 60%, #070b14 100%);
        min-height: 100vh;
      }

      header {
        position: sticky;
        top: 0;
        z-index: 20;
        backdrop-filter: blur(10px);
        background: rgba(6, 10, 20, 0.78);
        border-bottom: 1px solid var(--border);
      }

      .wrap { max-width: 1180px; margin: 0 auto; padding: 14px 14px; }

      .nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
      }

      .brand {
        display: flex;
        align-items: center;
        gap: 10px;
        font-weight: 800;
        letter-spacing: 0.2px;
      }
      .dot {
        width: 10px; height: 10px; border-radius: 999px;
        background: var(--accent);
        box-shadow: 0 0 0 4px rgba(255, 138, 0, 0.20);
      }
      .tiny { font-size: 11px; color: var(--muted); font-weight: 600; }

      .navRight {
        display: flex;
        gap: 10px;
        align-items: center;
      }

      .pill {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.04);
        padding: 6px 10px;
        border-radius: 999px;
        font-size: 12px;
        color: var(--muted);
      }
      .pill .lucide {
        width: 12px;
        height: 12px;
        stroke-width: 2.1;
      }
      .pDot { width: 8px; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.25); }
      .pDot.ok { background: var(--ok); }
      .pDot.warn { background: var(--warn); }
      .pDot.bad { background: var(--danger); }

      button {
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.06);
        color: var(--text);
        padding: 10px 12px;
        border-radius: 12px;
        cursor: pointer;
        transition: transform 0.05s ease, background 0.15s ease, opacity 0.15s ease;
        font-weight: 700;
        user-select: none;
      }
      .btnIcon {
        display: inline-flex;
        align-items: center;
        gap: 6px;
      }
      .btnIcon .lucide {
        width: 14px;
        height: 14px;
        stroke-width: 2.1;
      }
      button:hover { background: rgba(255,255,255,0.10); }
      button:active { transform: translateY(1px); }
      button.primary { border-color: rgba(255, 138, 0, 0.45); background: rgba(255, 138, 0, 0.16); }
      button.danger { border-color: rgba(255, 77, 77, 0.45); background: rgba(255, 77, 77, 0.14); }
      button:disabled { opacity: 0.5; cursor: not-allowed; }

      /* --- layout with sidebar --- */
      .shell {
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: 14px;
        max-width: 1180px;
        margin: 0 auto;
        padding: 14px;
      }

      .sidebar {
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.03);
        border-radius: 18px;
        overflow: hidden;
        box-shadow: 0 20px 60px rgba(0,0,0,0.25);
        height: calc(100vh - 92px);
        display: flex;
        flex-direction: column;
      }

      .sideHd {
        padding: 12px 12px;
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
      }

      .sideTitle { font-weight: 900; font-size: 13px; }
      .sideBd { padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }

      .chatItem {
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.04);
        border-radius: 12px;
        padding: 10px 10px;
        cursor: pointer;
        transition: background 0.15s ease, transform 0.05s ease;
        position: relative;
        padding-bottom: 34px;
      }
      .chatItem:hover { background: rgba(255,255,255,0.08); }
      .chatItem:active { transform: translateY(1px); }
      .chatItem.active { border-color: rgba(255, 138, 0, 0.45); background: rgba(255, 138, 0, 0.10); }

      .chatItem .t { font-weight: 900; font-size: 12px; margin-bottom: 4px; }
      .chatItem .m { font-size: 11px; color: var(--muted); }
      .chatItem .actions {
        display: flex;
        gap: 6px;
        position: absolute;
        right: 8px;
        bottom: 6px;
      }
      .chatItem .actions button { padding: 4px 6px; border-radius: 8px; font-size: 10px; }

      @media (max-width: 980px) {
        .shell { grid-template-columns: 1fr; }
        .sidebar { height: auto; }
      }

      .chat {
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.04);
        border-radius: 18px;
        overflow: hidden;
        box-shadow: 0 20px 60px rgba(0,0,0,0.35);
        position: relative;
        display: flex;
        flex-direction: column;
        height: calc(100vh - 92px);
      }

      .chatHeader {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 14px;
        border-bottom: 1px solid var(--border);
        background: rgba(255,255,255,0.03);
        min-height: 44px;
      }
      .chatTitle {
        font-weight: 900;
        font-size: 13px;
        letter-spacing: 0.2px;
      }
      .chatActions {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        display: flex;
        gap: 8px;
      }

      .chatBody {
        padding: 14px;
        flex: 1;
        height: auto;
        overflow: auto;
      }

      .msgRow {
        display: flex;
        gap: 10px;
        margin: 10px 0;
      }
      .msgRow.user { justify-content: flex-end; }
      .bubble {
        max-width: 78%;
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.05);
        padding: 10px 12px;
        border-radius: 14px;
        line-height: 1.45;
        white-space: pre-wrap;
        word-break: break-word;
        font-size: 14px;
      }
      .user .bubble {
        border-color: rgba(255, 138, 0, 0.35);
        background: rgba(255, 138, 0, 0.12);
      }

      .metaLine {
        margin-top: 6px;
        font-size: 11px;
        color: var(--muted);
      }

      .chips {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        padding: 12px 14px;
        border-top: 1px solid var(--border);
        background: rgba(255,255,255,0.03);
      }

      .chatToolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 14px;
        border-top: 1px solid var(--border);
        background: rgba(255,255,255,0.03);
      }
      .iconBtn {
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.06);
        color: var(--text);
        padding: 8px 10px;
        border-radius: 12px;
        font-size: 14px;
        cursor: pointer;
      }
      .iconBtn svg {
        width: 18px;
        height: 18px;
        stroke-width: 2;
        display: block;
      }
      .chatGear {
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 5;
      }

      .composer {
        display: flex;
        gap: 10px;
        padding: 12px 14px;
        border-top: 1px solid var(--border);
        background: rgba(255,255,255,0.03);
        align-items: center;
      }

      .welcome {
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.04);
        border-radius: 16px;
        padding: 16px;
        max-width: 640px;
        margin: 40px auto;
        box-shadow: 0 20px 60px rgba(0,0,0,0.25);
      }
      .welcome .title { font-weight: 900; font-size: 18px; margin-bottom: 6px; }
      .welcome .subtitle { color: var(--muted); margin-bottom: 12px; }
      .welcome .suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
      .welcome .suggestions button { font-size: 12px; padding: 8px 10px; border-radius: 999px; }

      input[type="text"] {
        width: 100%;
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.05);
        color: var(--text);
        padding: 12px 12px;
        border-radius: 12px;
        outline: none;
        font-size: 14px;
      }

      .micBtn {
        width: 44px;
        display: grid;
        place-items: center;
        font-size: 16px;
      }
      .micBtn svg {
        width: 18px;
        height: 18px;
        stroke-width: 2;
        display: block;
      }
      .micBtn.listening svg { stroke: var(--danger); }

      .overlay {
        position: fixed;
        inset: 0;
        background: rgba(6,10,20,0.55);
        backdrop-filter: blur(2px);
        display: none;
        place-items: center;
        z-index: 50;
      }
      .overlay.show { display: grid; }
      .loaderCard {
        border: 1px solid var(--border);
        background: rgba(10, 16, 30, 0.92);
        border-radius: 16px;
        padding: 14px 16px;
        width: min(520px, calc(100vw - 32px));
        box-shadow: 0 30px 80px rgba(0,0,0,0.55);
      }
      .spinnerRow { display: flex; align-items: center; gap: 10px; }
      .spinner {
        width: 16px; height: 16px; border-radius: 50%;
        border: 2px solid rgba(255,255,255,0.18);
        border-top-color: rgba(255, 138, 0, 0.9);
        animation: spin 0.8s linear infinite;
      }
      @keyframes spin { to { transform: rotate(360deg); } }
      .loaderTitle { font-weight: 900; font-size: 13px; }
      .loaderMsg { margin-top: 6px; font-size: 12px; color: var(--muted); white-space: pre-wrap; }

      .typingRow { display: flex; gap: 10px; margin: 10px 0; }
      .typingBubble {
        max-width: 78%;
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.05);
        padding: 10px 12px;
        border-radius: 14px;
        line-height: 1.45;
        font-size: 14px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
      }
      .dotPulse {
        width: 6px; height: 6px; border-radius: 50%;
        background: rgba(232,238,252,0.7);
        animation: pulse 1.2s infinite ease-in-out;
      }
      .dotPulse:nth-child(2) { animation-delay: 0.15s; }
      .dotPulse:nth-child(3) { animation-delay: 0.3s; }
      @keyframes pulse {
        0%, 80%, 100% { opacity: 0.2; transform: translateY(0); }
        40% { opacity: 1; transform: translateY(-3px); }
      }

      .toast {
        position: fixed;
        right: 16px;
        bottom: 16px;
        width: min(520px, calc(100vw - 32px));
        border-radius: 14px;
        border: 1px solid var(--border);
        background: rgba(10, 16, 30, 0.92);
        padding: 12px 12px;
        display: none;
        z-index: 60;
        box-shadow: 0 20px 60px rgba(0,0,0,0.45);
      }
      .toast.show { display: block; }
      .toast .t { font-size: 13px; font-weight: 900; margin-bottom: 6px; }
      .toast .m { font-size: 12px; color: var(--muted); white-space: pre-wrap; }

      .drawerMask {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        display: none;
        z-index: 40;
      }
      .drawerMask.show { display: block; }

      .drawer {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: min(520px, 92vw);
        background: rgba(10, 16, 30, 0.96);
        border-left: 1px solid var(--border);
        transform: translateX(100%);
        transition: transform 0.18s ease;
        z-index: 45;
        display: flex;
        flex-direction: column;
      }
      .drawer.show { transform: translateX(0); }
      .drawerHd {
        padding: 14px;
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
      }
      .drawerBd { padding: 14px; overflow: auto; }
      pre {
        margin: 0;
        font-family: var(--mono);
        font-size: 12px;
        line-height: 1.45;
        color: rgba(232,238,252,0.95);
        white-space: pre-wrap;
        word-break: break-word;
      }
      .sectionTitle {
        font-size: 12px;
        color: rgba(232,238,252,0.9);
        font-weight: 900;
        margin: 14px 0 8px;
      }
      a { color: var(--accent); text-decoration: none; }
      a:hover { text-decoration: underline; }

      .planTitle { font-weight: 900; font-size: 15px; margin-bottom: 6px; }
      .planSummary { color: var(--muted); margin-bottom: 8px; }
      .planSection { margin-top: 10px; }
      .planHeading { font-weight: 800; font-size: 13px; margin: 8px 0 6px; }
      .planSection ul, .planSection ol { margin: 6px 0 6px 18px; }
      .planChecklist { list-style: none; margin-left: 0; padding-left: 0; }
      .planChecklist li { margin: 4px 0; }
      .planChecklist input { margin-right: 6px; }
      .planActions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
      .planActions a { color: var(--accent); font-size: 12px; }
